// Fill out your copyright notice in the Description page of Project Settings.


#include "Player/TUPlayerController.h"
#include "Component/TURespawnComponent.h"
#include "TUGameModeBase.h"
//#include "TUGameInstance.h"

ATUPlayerController::ATUPlayerController()
{
    RespawnComponent = CreateDefaultSubobject<UTURespawnComponent>("RespawnComponent");
}

//void ATUPlayerController::BeginPlay()
//{
//    Super::BeginPlay();
//
//    if (GetWorld())
//    {
//        if (const auto GameMode = Cast<ATUGameModeBase>(GetWorld()->GetAuthGameMode()))
//        {
//            GameMode->OnMatchStateChanged.AddUObject(this, &ATUPlayerController::OnMatchStateChanged);
//        }
//    }
//}
//
//void ATUPlayerController::OnMatchStateChanged(ETUMatchState State)
//{
//    if (State == ETUMatchState::InProgress)
//    {
//        SetInputMode(FInputModeGameOnly());
//        bShowMouseCursor = false;
//    }
//    else
//    {
//        SetInputMode(FInputModeUIOnly());
//        bShowMouseCursor = true;
//    }
//}

//void ATUPlayerController::OnPossess(APawn* InPawn)
//{
//    Super::OnPossess(InPawn);
//
//    OnNewPawn.Broadcast(InPawn);
//}

//void ATUPlayerController::SetupInputComponent()
//{
//    Super::SetupInputComponent();
//    if (!InputComponent) return;
//
//    InputComponent->BindAction("PauseGame", IE_Pressed, this, &ATUPlayerController::OnPauseGame);
//    InputComponent->BindAction("Mute", IE_Pressed, this, &ATUPlayerController::OnMuteSound);
//}

//void ATUPlayerController::OnPauseGame()
//{
//    if (!GetWorld() || !GetWorld()->GetAuthGameMode()) return;
//
//    GetWorld()->GetAuthGameMode()->SetPause(this);
//}
//
//void ATUPlayerController::OnMuteSound()
//{
//    if (!GetWorld()) return;
//
//    const auto TUGameInstace = GetWorld()->GetGameInstance<UTUGameInstance>();
//    if (!TUGameInstace) return;
//
//    TUGameInstace->ToggleVolume();
//}